<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        * {
            margin: 0;
            padding: 0;
        }

        .box {
            width: 100%;
            height: 60px;
            /* background-color: pink; */
            margin-top: 20px;
        }

        .box input {
            width: 80%;
            height: 40px;
            outline: none;
            background-color: #ccc;
            border: 0;
            margin-left: 20px;
            border-radius: 30px;
        }

        .box span {
            color: aqua;
            margin-left: 10px;
        }

        .item {
            width: 60%;
            height: 40px;
            background-color: #ccc;
            margin-left: 20px;
            text-align: center;
            line-height: 40px;
            margin-top: 10px;
            margin-bottom: 10px;
        }

        .box3 {
            width: 100%;
            height: 150px;
        }

        .box3 span {
            /* display: inline-block;
            height: 30px; */
            /* background-color: #ccc; */
            margin-left: 20px;
            margin-top: 10px;
            line-height: 30px;
        }

        .one {
            position: relative;
        }

        .one span {
            position: absolute;
            top: 0;
            right: 15px;
        }
    </style>
</head>

<body>
    <div id="app">
        <h2>&lt;搜索</h2>
        <div class="box">
            <input type="text" placeholder="搜索商家、商品名称" v-model="inputText"><span @click="add()">搜索</span>
        </div>
        <div class="one">
            <h3>历史搜索</h3><span @click="clear()">清空</span>
        </div>
        <div class="item" v-for="(item,index) in tasklist">{{item}}</div>
        <h3>搜索发现</h3>
        <div class="box3">
            <span class="item" v-for(item,index)in box3list>{{item}}</span>
        </div>
    </div>
    <script src="./vue-2.5.21.js"></script>
</body>

</html>
<script>
    var v = new Vue({
        el: '#app',
        data: {
            inputText: '',
            tasklist: ['天天鲜挪威三文鱼(立水桥店)'],
            box3list: ['肠粉', '米线', '汉堡', '老碗鱼', '汉堡', '鸡腿', '麻辣烫', '蟹肉煲']
        },
        methods: {
            add() {
                if (this.inputText) {
                    this.tasklist.push(this.inputText)
                    this.inputText = ''
                }
            },
            clear() {
                this.tasklist = []
            }
        }
    })
</script>